﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta charset="UTF-8">
    <title>更新仓库信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link href="~/Content/X-admin/css/font.css" rel="stylesheet" />
    <script src="~/Content/X-admin/lib/layui/layui.js"></script>
    <link href="~/Content/X-admin/css/xadmin.css" rel="stylesheet" />
    <script src="~/Content/X-admin/js/jquery.min.js"></script>
    <script src="~/Content/X-admin/js/xadmin.js"></script>
    <script src="~/Content/Scripts/System/systemFrame.js"></script>
    <script src="~/Content/Scripts/System/Common.js"></script>
</head>
<body>
    <div class="layui-fluid">
        <div class="layui-row">
            <span style="margin-top:15px;margin-left:15px">
                <xblock>
                    <button class="layui-btn" onclick="saveData()"><i class="layui-icon"></i>保存</button>
                    <button class="layui-btn" onclick="closeWin()"><i class="layui-icon">&#x1006;</i>取消</button>
                </xblock>
            </span>
            <div style="margin: 20px; border: 1px solid #dbdbdb;padding:15px">
                <form class="layui-form" id="wForm">
                    <div class="layui-form-item">
                        <label class="layui-form-label">仓库编码</label>
                        <div class="layui-input-inline">
                            <input type="text" name="houseCode" required lay-verify="required" placeholder="请输入仓库编码" autocomplete="off" class="layui-input" id="houseCode" maxlength="10">
                            <input type="hidden" name="id" id="id">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">仓库名称</label>
                        <div class="layui-input-inline">
                            <input type="text" name="houseName" required lay-verify="required" placeholder="请输入仓库名称" autocomplete="off" class="layui-input" id="houseName" maxlength="10">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label for="L_email" class="layui-form-label">是否启用</label>
                        <div class="layui-input-inline">
                            <select name="status" id="status" class="valids"></select>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</body>
</html>
<script>

    var dataId = ''

    $(function () {
        DictionaryDropDown("ps", "status", "open");
        dataId = getUrlVariable("dataId");
        if (dataId != '0') {
            $("input[name='id']").val(dataId);
            loadData(dataId);
        }
    })

    /**数据保存**/
    function saveData() {
        $.ajax({
            url: '../Basis/UpdateWareHouseInfo',
            type: 'post',
            data: { data: JSON.stringify(FormToJson("wForm")) },
            dataType: 'json',
            success: function (rsl) {
                if (rsl.Result) {
                    var id = $("input[ name='id']").val();

                    var msg = "信息修改成功!";
                    if (id == "0" || id == "") {
                        msg = "信息添加成功!";
                    }
                    layer.alert(msg, { icon: 6 }, function () {
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                    });
                } else {
                    layer.msg(rsl.Message);
                }
            }

        })
    }

    //获取数据
    function loadData() {
        $.ajax({
            url: '../Basis/getWareHouseInfoById',
            type: 'post',
            data: { dataId: dataId },
            success: function (rsl) {
                if (rsl.Result) {
                    $.each(rsl.Data[0], function (name, value) {
                        if (name != "status") {
                            $("input[ name='" + name + "']").val(value);
                        } else {
                            $("#" + name + "").val(value);
                        }
                    })

                    layui.use('form', function () {
                        var form = layui.form
                        form.render()
                    })
                }
            }
        })
    }

</script>
